<?php

class AuthentificationService {
	
	function authentificate($username, $passwd) {
	
		$this->_helper->layout->setLayout('layout');
		$this->view->huhu = "abc";

		$db = BaseController::getDBConnection();
		$db->getConnection();
		
		$auth = Zend_Auth::getInstance();
		$authAdapter = new Zend_Auth_Adapter_DbTable($db);
		$authAdapter->setTableName("user");
		$authAdapter->setIdentityColumn("name");
		$authAdapter->setCredentialColumn("passwd");
		
		$authAdapter->setIdentity("sven");
		$authAdapter->setCredential("abc");
		
		$result = $auth->authenticate($authAdapter);
		
		if ($result->isValid()) {
	 		$auth->getStorage()->write($authAdapter->getResultRowObject());
	 		Zend_Debug::dump($auth->getIdentity());
		}
		
		else {
			$auth->clearIdentity();
		}
	}
	
}